import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 周斌
 * Date: 2024-05-15
 * Time: 10:37
 */
//day8 贪心算法练习 力扣455 分发饼干
public class Main {
    public int findContentChildren(int[] g, int[] s) {
        //1.排序
        int n = s.length;
        Arrays.sort(g);
        Arrays.sort(s);
        //2.遍历数组
        int count = 0;
        int j = 0;
        for(int i = 0; i < g.length; i++) {
            while(j < n) {
                //饼干尺寸大于等于胃口
                if(s[j] >= g[i]) {
                    count++;
                    j++;
                    break;
                } else {
                    j++;
                }
            }
        }
        return count;
    }
}
